
seq={'sum':7854081365.000000,
'N':1,
'PI':3.141774,
'time':'4:25.744'} 

n6={'sum':625252057.000000 + 1095643715.000000+ 1350140080.000000+ 1512565510.000000+ 1611656732.000000+ 1658959957.000000,
'PI':3.141687,
'N':6,
'time':'0:56.132'} 


n10={'sum':936249284.000000 +967792863.000000 +988260414.000000 +998435489.000000 +293656194.000000 +523932788.000000 +660059405.000000 +759062591.000000 +834536467.000000 +892450375.000000,
'PI':3.141774,
'N':10,
'time':'1:3.981'}

n12={'sum':740370671.000000 +772284298.000000 +796892656.000000 +814860035.000000 +826620748.000000 +832438507.000000 +223972283.000000 +401306431.000000 +508109770.000000 +587596450.000000 +650070002.000000 +700149075.000000,
'PI':3.141868,
'N':12,
'time':'0:51.857'} 


n20={'sum':496027847.000000 +498641425.000000 +499794064.000000 +409065812.000000 +452530087.000000 +463450526.000000 +472798758.000000 +480666712.000000 +487126151.000000 +344286144.000000 +368855285.000000 +390283300.000000 +425554172.000000 +439920288.000000 +492232567.000000 +104633123.000000 +315839405.000000 +189054296.000000 +241649822.000000 +282335645.000000,
'PI':3.141898,
'N':20,
'time':'0:54.264'} 

n24={'sum':401095028.000000 +405580174.000000 +409280204.000000 +412216282.000000 +414404684.000000 +416581414.000000 +355673915.000000 +365705822.000000 +374665614.000000 +382628671.000000 +389656215.000000 +395798099.000000 +242771479.000000 +302525641.000000 +318076932.000000 +344476091.000000 +331994238.000000 +415857168.000000 +79700895.000000 +184836288.000000 +285072281.000000 +216472938.000000 +144280912.000000 +265340256.000000,
'PI':3.141876,
'N':24,
'time':'0:46.181'} 


n40={'sum':247620162.000000 +248506901.000000 +249135411.000000 +249605733.000000 +249818935.000000 +250075098.000000 +239439374.000000 +241227338.000000 +242841341.000000 +244284810.000000 +245560749.000000 +246671818.000000 +224797484.000000 +227732603.000000 +230460886.000000 +232989640.000000 +235325265.000000 +237473493.000000 +86876530.000000 +206771720.000000 +210890648.000000 +214748635.000000 +221647382.000000 +218272906.000000 +202375908.000000 +175470619.000000 +181602940.000000 +187326127.000000 +192676618.000000 +197684745.000000 +168884400.000000 +126515751.000000 +136625246.000000 +145766912.000000 +154113685.000000 +161788917.000000 +115182484.000000 +37139984.000000 +67515360.000000 +102215762.000000,
'PI':3.142264,
'N':40,
'time':'0:46.25'} 

n48={'sum':167683013.000000 +205837505.000000 +207024629.000000 +207479414.000000 +207842515.000000 +208385874.000000 +208295491.000000 +194052503.000000 +198660671.000000 +199984716.000000 +204274701.000000 +208114413.000000 +206477584.000000 +197232172.000000 +201206384.000000 +205103567.000000 +203349805.000000 +202327509.000000 +195696974.000000 +188433940.000000 +192295950.000000 +184081913.000000 +186321213.000000 +190424246.000000 +179204156.000000 +181711288.000000 +173756372.000000 +176554688.000000 +130073056.000000 +140255797.000000 +144884149.000000 +170801913.000000 +157239434.000000 +160913240.000000 +78049890.000000 +124442815.000000 +135330032.000000 +149242860.000000 +153354788.000000 +164390364.000000 +118385957.000000 +111833048.000000 +51441397.000000 +66263741.000000 +104690677.000000 +88051218.000000 +28273062.000000 +96828010.000000,
'PI':3.142623,
'N':48,
'time':'0:48.736'} 


res = [ n6, n10, n12, n20, n24, n40, n48 ]


def to_milis( str ):
	s_ms = 1000.0
	m_ms = 60*s_ms
	tmp = str.split(":")
	m = int(tmp[0])
	tmp = tmp[1].split(".")
	s = int(tmp[0])
	ms = int(tmp[1]) 	
	return (m*m_ms) + (s*s_ms) + ms

seq['milis'] = to_milis( seq['time'] )
for i in res:
	i['milis'] = to_milis( i['time'] )


def speedup( seq, par ):
	return seq / par

sum_sort = lambda x, y: cmp(y['sum'], x['sum'])
res.sort(sum_sort)

for i in res:
	r = res[0]['sum']
	i['perc'] = (i['sum']/r)*100
	i['speedup'] = speedup(seq['milis'], i['milis'])

format = "%-8s %-13s %-10s %-10s %-3s %-15s %-10s"

print format % \
	("PI", "Iterations", "Time", "Milis", "N", "%", "Speedup")
for i in res:
	print format % \
		(i['PI'], i['sum'], i['time'], i['milis'], i['N'], i['perc'], i['speedup'])
print
seq['perc'] = 0
seq['speedup'] = 0
print format % \
	(seq['PI'], seq['sum'], seq['time'], seq['milis'], seq['N'], seq['perc'], seq['speedup'])

import math
print math.pi
